<?php
/*
  项目名称:校内网应用|吼吼
  作者:我不叫大脸猫
  版本beta1.0
  功能:1.发送自定义形式的好友新鲜事 2.向好友发送通知  3.邀请好友安装应用
      其他功能待定
  项目配置
*/
error_reporting(-1);
define('IN_APP',true);
define('ROOT',dirname(__FILE__).'/');
define('EXT','php');
define('API_KEY','d531777fa70643d5ba90d3f6b819060e');   //填入项目api_key
define('SECRET','118ef0c063494224b3c683d48b571253');    //填入项目secret
//加载全局配置文件
$config = parse_ini_file(ROOT.'lib/config.ini.'.EXT);
//加载执行文件
require_once(ROOT.'lib/db.inc.'.EXT);
require_once(ROOT.'lib/view.inc.'.EXT);
require_once(ROOT.'lib/controller.inc.'.EXT);
//unset以下超全局变量,缩小可用全局变量的范围,增强对于全局变量的控制力
unset($GLOBALS, $_ENV, $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_COOKIE_VARS, $HTTP_SERVER_VARS, $HTTP_ENV_VARS);
//过滤用户输入
$_GET =& filters($_GET,true);
$_POST =& filters($_POST,true);
$_REQUEST =& filters($_REQUEST,true);
$config['sitecondition']=='off'?exit('site is under repaired!'):'';
if(!isset($_REQUEST['m'])){
	$_REQUEST['m'] = 'index';
	$_REQUEST['a'] = 'run';
}
if (in_array($_REQUEST['m'],array('index','hoho','show-friends','select-templet','notification'))) {
	require_once(ROOT."controller/$_REQUEST[m].".EXT);
	$controller = new controller(API_KEY,SECRET);
	if (method_exists($controller,$_REQUEST['a'])) {
		$controller->$_REQUEST['a']();
	}else {
		exit('action is not exists!');
	}
}else {
	exit('you are accessing a wrong controller!');
}

//过滤函数
function filters($input, $strip = false){
	if (get_magic_quotes_gpc()) {
		if (is_array($input)) {
			foreach ($input as $key => $item){
				$input[$key] = filters($item);
			}
		}else {
			$input = addslashes($strip?stripslashes($input):$input);
		}
	}
	return $input;
}